-module(pt_room_joined_d011).
-include("pt.hrl").

-export([new/0,from_binary/1,to_binary/1,to_binary/2,get_id/0]).

get_id()-> 16#D011.

new()->#pt_room_joined{}.

from_binary(Binary) -> 
	{Binary1,Data1} = lib_protocol:from_binary(Binary,uint32),
	{Binary2,Data2} = lib_protocol:from_binary(Binary1,uint32),
	{Binary3,Data3} = lib_protocol:from_binary(Binary2,string),
	{_Binary,Data4} = lib_protocol:from_binary(Binary3,string),
	#pt_room_joined{
		room_id = Data1,
		room_type = Data2,
		room_rule = Data3,
		room_psw = Data4
	}.

to_binary(Pt) -> to_binary(Pt,0).
to_binary(Pt,Seq) -> 
	Data1 = lib_protocol:to_binary(Pt#pt_room_joined.room_id,uint32),
	Data2 = lib_protocol:to_binary(Pt#pt_room_joined.room_type,uint32),
	Data3 = lib_protocol:to_binary(Pt#pt_room_joined.room_rule,string),
	Data4 = lib_protocol:to_binary(Pt#pt_room_joined.room_psw,string),
	GetData = <<Data1/binary,Data2/binary,Data3/binary,Data4/binary>>,
	lib_protocol:make_pt(GetData,get_id(),Seq).

